package org.zjut.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zjut.db.AttributeDataBase;
import org.zjut.db.GeneratorDataBase;
import org.zjut.db.ResourceDataBase;
import org.zjut.util.CommonUtil;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author Rising
 * @date 2017/8/20
 * @des 生成数据类
 */
@Controller
public class Generator {
    @Autowired
    AttributeDataBase attributeDataBase;
    @Autowired
    ResourceDataBase resourceDataBase;
    @Autowired
    GeneratorDataBase generatorDataBase;

    SimpleDateFormat sdf  = new SimpleDateFormat("yy-dd-mm_HH:mm:ss");
//    /**
//     * 随机生成学习资源
//     * 普通资源，暂不包括学习概念
//     * @return
//     */
//    @RequestMapping(value = "/generateResource/{count}", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public String generateResources(@PathVariable String count){
//        int mCount = -1;
//        try{
//            mCount = Integer.valueOf(count);
//        }catch (Exception e){
//            return JSON.toJSONString(CommonUtil.setErrorInfo("请检查参数"));
//        }
//        try{
//            return JSON.toJSONString(generatorDataBase.generateResources(count));
//        }catch (Exception e){
//            return JSON.toJSONString(CommonUtil.setErrorInfo("生成失败"));
//        }
//    }
//
//    /**
//     * 随机生成多名学习者，并根据属性的上下限随机赋值
//     * @return
//     */
//    @RequestMapping(value = "/generateLearner/{count}", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public String generateLearner(@PathVariable String count){
//        int mCount = -1;
//        try{
//            mCount = Integer.valueOf(count);
//        }catch (Exception e){
//            return JSON.toJSONString(CommonUtil.setErrorInfo("请检查参数"));
//        }
//
//        try {
//            return JSON.toJSONString(generatorDataBase.GenerateLearner(mCount));
//        }catch (Exception e){
//            return JSON.toJSONString(CommonUtil.setErrorInfo("生成失败"));
//        }
//    }
}
